package com.pro.common.service.sitecontent.service;

import com.pro.common.service.sitecontent.dao.CurrencyDao;
import com.pro.common.service.sitecontent.model.db.Currency;
import com.pro.framework.mybatisplus.BaseService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 国家 服务实现类
 */
@Service
@AllArgsConstructor
public class CurrencyService extends BaseService<CurrencyDao, Currency> {

    public Map<String, BigDecimal> getRateMap() {
        return this.lambdaQuery()
                .list()
                .stream()
                .collect(Collectors.toMap(Currency::getCode, Currency::getUsdToCurrentRate));
    }

//    public Map<String, Currency> getMap(Collection<String> propValues) {
//        return super.getMap(Currency::getCode, propValues);
//    }
}
